namespace jQube.Web.UI.Controls
{
    using System;
    using System.Collections;
    using System.Collections.Generic;

    public class AccordionPaneEnumerator : IEnumerator<AccordionPane>
    {
        private AccordionPaneCollection accordionPaneCollection;
        private IEnumerator enumerator;

        private AccordionPaneEnumerator()
        {
        }

        internal AccordionPaneEnumerator(AccordionPaneCollection accordionPaneCollection)
        {
            this.accordionPaneCollection = accordionPaneCollection;
            this.enumerator = accordionPaneCollection.Parent.Controls.GetEnumerator();
        }

        #region IEnumerator<AccordionPane> Members

        public AccordionPane Current
        {
            get { return this.enumerator.Current as AccordionPane; }
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            this.enumerator = null;
            this.accordionPaneCollection = null;
            GC.SuppressFinalize(this);
        }

        #endregion

        #region IEnumerator Members

        object IEnumerator.Current
        {
            get { return this.Current; }
        }

        public bool MoveNext()
        {
            return this.enumerator.MoveNext();
        }

        public void Reset()
        {
            this.enumerator.Reset();
        }

        #endregion
    }
}
